package jin.si.com.handler;

import jin.si.com.utils.JsonData;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @description: 异常
 * @ClassName HandlerTestException
 * @Author MT
 * @Date 2021/5/10 10:23
 **/
//@ControllerAdvice
@RestControllerAdvice
public class HandlerTestException {

    /*//@ResponseBody
    @ExceptionHandler(value=Exception.class)
    public JsonData getExec(Exception e, HttpServletRequest req){
        return JsonData.buildError("服务器出问题了");
    }*/

   @ExceptionHandler(value=Exception.class)
   public ModelAndView getExc(){
        ModelAndView m=new ModelAndView();
        m.setViewName("erroy.html");
        m.addObject("msg","服务器出问题了");
        return m;


   }



}
